package com.xlhj.multiple.dao;

import com.xlhj.multiple.entity.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName SysUserDao
 * @Description 用户表持久层
 * @Author liucaijing
 * @Date 2021/2/24 11:16
 * @Version 1.0
 */
@Repository
public class SysUserDao {

    @Resource(name = "jdbcTemplateOne")
    private JdbcTemplate jdbcTemplateOne;

    @Autowired
    @Qualifier("jdbcTemplateTwo")
    private JdbcTemplate jdbcTemplateTwo;

    /**
     * 查询one库全部用户信息
     * @return
     */
    public List<SysUser> selectAllUserOne() {
        List<SysUser> userList = jdbcTemplateOne.query("select * from sys_user", new BeanPropertyRowMapper<>(SysUser.class));
        return userList;
    }

    /**
     * 查询two库全部用户信息
     * @return
     */
    public List<SysUser> selectAllUserTwo() {
        List<SysUser> userList = jdbcTemplateTwo.query("select * from sys_user", new BeanPropertyRowMapper<>(SysUser.class));
        return userList;
    }
}
